/*
 * @Author: dadadaXU 1413107032@qq.com
 * @Date: 2025-01-14 19:46:15
 * @LastEditors: dadadaXU 1413107032@qq.com
 * @LastEditTime: 2025-01-14 21:17:54
 * @FilePath: \leetcode\1.两数之和.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/*
 * @lc app=leetcode.cn id=1 lang=cpp
 *
 * [1] 两数之和
 */
#include <vector>
#include <unordered_map>

using namespace std;

// @lc code=start
class Solution
{
public:
    unordered_map<int, int> hash_strs;

    vector<int> twoSum(vector<int> &nums, int target)
    {
        for (int i = 0; i < nums.size(); i++)
        {
            if (hash_strs.find(target - nums[i]) != hash_strs.end())
            {
                return {hash_strs[target - nums[i]], i};
            }
            hash_strs[nums[i]] = i;
        }
        return {};
    }
};

// @lc code=end
